package cn.dcw.pethome.basic.config;

import cn.dcw.pethome.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 定义拦截规则
 */
@Configuration//标识这个类是一个配置类
public class WebMvcConfig implements WebMvcConfigurer{

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //设置拦截
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")//拦截所有
                //不包含
                .excludePathPatterns("/login/**")
                .excludePathPatterns("/user/phone/register/**")
                .excludePathPatterns("/emp/**")
                .excludePathPatterns("/dept/**")
                .excludePathPatterns("/detail/**")
                .excludePathPatterns("/type/**")
                .excludePathPatterns("/verifycode/sendSmsCode/**")
                .excludePathPatterns("/phoneVerify/**")
                .excludePathPatterns("/fastDfs/**")
                .excludePathPatterns("/shop/**")
                .excludePathPatterns("/pet/**")
                .excludePathPatterns("/product/**")
                .excludePathPatterns("/searchMasterMsg/**")
                .excludePathPatterns("/searchMasterMsg/**/**");
    }

}
